Sample Code - CloseButtonClicked Event

This sample code shows the use of the CloseButtonClicked Event (Window Object). Modify the following sample code to fit your needs.

Dim rpt As CRPEAuto.Report
Dim rptView As CRPEAuto.View
Dim test As Integer

Private Sub CloseButtonClicked_Click()
'Starts up report window for window event CloseButtonClicked


On Error GoTo ErrorHandler
Set rpt = crsApp.OpenReport("c:\crw\reports\xtreme\www.sales.rpt")
rpt.PrintWindowOptions.CanDrillDown = True
test = MsgBox("Event default: Enabled = " & _
    rpt.EventInfo.PrintWindowButtonEventEnabled & _
    Chr(13) & Chr(13) & "Disable event?", vbYesNo)
If test = vbYes Then
rpt.EventInfo.PrintWindowButtonEventEnabled = False
MsgBox "Check event does not occur when close button clicked"
Else
rpt.EventInfo.PrintWindowButtonEventEnabled = True
test = MsgBox("Check event occurs when close drill down _
        view button clicked (drill down on group to enable it)" & _
        Chr(13) & Chr(13) & "Use default behaviour for test? ", vbYesNo)
If test = vbYes Then
def = True
Else
def = False
End If
End If

Set rptView = rpt.Preview
Set windowEvs = rptView.Parent
Exit Sub ' Exit to avoid handler.

Private Sub windowEvs_CloseButtonClicked(ByVal ViewIndex As Integer, useDefault As Boolean)
'executed when close button clicked - test using default and _
'not using default behaviour
If def Then
'test for default behaviour:
MsgBox "Window CloseButtonClicked event" & Chr(13) & Chr(13) & _
        "Parameters:" & Chr(13) & "ViewIndex: " & ViewIndex & _
        Chr(13) & "useDefault: " & useDefault & Chr(13) & Chr(13) & _
        "Drill down view should now close"
Else
'test for no default behaviour:
useDefault = False
MsgBox "Window CloseButtonClicked event" & Chr(13) & Chr(13) & _
        "Parameters:" & Chr(13) & "ViewIndex: " & ViewIndex & _
        Chr(13) & "useDefault: " & useDefault & Chr(13) & Chr(13) & _
        "Drill down view should NOT close"
End If
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com